//
//  ToolWindow.cpp
//  Editor
//
//  Created by Jeppe Nielsen on 10/19/14.
//  Copyright (c) 2014 Jeppe Nielsen. All rights reserved.
//

#include "ToolWindow.hpp"
#include "MainWindow.hpp"

#include <QtWidgets/QtWidgets>

using namespace Qt;

ToolWindow::~ToolWindow() {}


void ToolWindow::Create(MainWindow *mainWindow, QMenu* toolWindowMenu, Context* context) {
    
    this->context = context;
    
    window = new QDockWidget(QString(GetName().c_str()), mainWindow);
    window->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
    
    mainWindow->addDockWidget(Qt::TopDockWidgetArea, window, Qt::Horizontal);
    
    toolWindowMenu->addAction(window->toggleViewAction());
    
    OnCreate();
}

void ToolWindow::Save() {
    if (!window->isActiveWindow()) return;
    if (!window->isVisible()) return;
    if (window->isHidden()) return;
    OnSave();
}

void ToolWindow::OnSave() {
    
}